package cn.tedu._05egweibo01.common.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

//    统一的返回值
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class JsonResult {
    private Integer state;
    private String message;
    private Object data;

    public JsonResult(StateCode stateCode){
        this.state = stateCode.getState();
        this.message = stateCode.getMessage();
    }

    public JsonResult(StateCode stateCode,Object data){
        this.state = stateCode.getState();
        this.message = stateCode.getMessage();
        this.data = data;
    }

    public static JsonResult ok(Object data){
        return new JsonResult(StateCode.OPERATION_SUCCESS,data);
    }

    public static JsonResult ok(){
        return  JsonResult.ok(null);
    }
}
